<?php

$htmlOutput = array();
$htmlOutput[] = '<div class="news index">';
$htmlOutput[] = sprintf('   <h2>%s</h2>', __('News', true));
$htmlOutput[] = '           <p>';
$htmlOutput[] =                 $paginator->counter(array('format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)));
$htmlOutput[] = '           </p>';
$htmlOutput[] = '           <table cellpadding="0" cellspacing="0">';
$htmlOutput[] = '               <tr>';
$htmlOutput[] = sprintf('           <th>%s</th>', $paginator->sort('id'));
$htmlOutput[] = sprintf('           <th>%s</th>', $paginator->sort('title'));
$htmlOutput[] = sprintf('           <th>%s</th>', $paginator->sort('introduction'));
$htmlOutput[] = sprintf('           <th>%s</th>', $paginator->sort('keywords'));
$htmlOutput[] = sprintf('           <th>%s</th>', $paginator->sort('body'));
$htmlOutput[] = sprintf('           <th>%s</th>', $paginator->sort('image'));
$htmlOutput[] = sprintf('           <th>%s</th>', $paginator->sort('created'));
$htmlOutput[] = sprintf('           <th>%s</th>', $paginator->sort('modified'));
$htmlOutput[] = sprintf('           <th>%s</th>', $paginator->sort('user_id'));
$htmlOutput[] = sprintf('           <th class="actions">%s</th>', __('Actions', true));
$htmlOutput[] = '               </tr>';
$i = 0;
foreach ($news as $news) {
    $class = null;
    if ($i++ % 2 == 0) {
        $class = ' class="altrow"';
    }
    $htmlOutput[] = sprintf('<tr %s>', $class);
    $htmlOutput[] = '		<td>';
    $htmlOutput[] =             $news['News']['id'];
    $htmlOutput[] = '		</td>';
    $htmlOutput[] = '		<td>';
    $htmlOutput[] =             $news['News']['title'];
    $htmlOutput[] = '		</td>';
    $htmlOutput[] = '		<td>';
    $htmlOutput[] =             $news['News']['introduction'];
    $htmlOutput[] = '		</td>';
    $htmlOutput[] = '		<td>';
    $htmlOutput[] =             $news['News']['keywords'];
    $htmlOutput[] = '		</td>';
    $htmlOutput[] = '		<td>';
    $htmlOutput[] =             $news['News']['body'];
    $htmlOutput[] = '		</td>';
    $htmlOutput[] = '		<td>';
    $htmlOutput[] =             $news['News']['image'];
    $htmlOutput[] = '		</td>';
    $htmlOutput[] = '		<td>';
    $htmlOutput[] =             $news['News']['created'];
    $htmlOutput[] = '		</td>';
    $htmlOutput[] = '		<td>';
    $htmlOutput[] =             $news['News']['modified'];
    $htmlOutput[] = '		</td>';
    $htmlOutput[] = '		<td>';
    $htmlOutput[] =             $html->link($news['User']['username'], 
                                            array('controller'=> 'users',                                      'action'=>'view', $news['User']['id']));
    $htmlOutput[] = '		</td>';
    $htmlOutput[] = '		<td class="actions">';
    $htmlOutput[] =             $html->link(__('View', true), 
                                            array('action'=>'view', $news['News']['id']));
    $htmlOutput[] =             $html->link(__('Edit', true), 
                                            array('action'=>'edit', $news['News']['id']));
    $htmlOutput[] =             $html->link(__('Delete', true), 
                                            array('action'=>'delete', $news['News']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $news['News']['id']));
    $htmlOutput[] = '		</td>';
    $htmlOutput[] = '	</tr>';
}
$htmlOutput[] = '</table>';
$htmlOutput[] = '</div>';
$htmlOutput[] = '<div class="paging">';
$htmlOutput[] =     $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
$htmlOutput[] = ' | ';
$htmlOutput[] = $paginator->numbers();
$htmlOutput[] = $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
$htmlOutput[] = '</div>';
$htmlOutput[] = '<div class="actions">';
$htmlOutput[] = '	<ul>';
$htmlOutput[] = sprintf('<li>%s</li>', $html->link(__('New News', true), array('action'=>'add')));
$htmlOutput[] = '	</ul>';
$htmlOutput[] = '</div>';

echo implode("\n", $htmlOutput);

?>